package thread;

/**
 * Created mangcao with 2019/5/31 10:29
 * Description: 死锁demo ,锁竞争问题
 */
public class DeadLock {

    private static Object a = new Object();
    private static Object b = new Object();

    public static void main(String[] args) throws InterruptedException {

        new Thread(() -> {
            synchronized (b) {
                System.out.println("xx");
                try {
                    Thread.sleep(600);
                    synchronized (a) {

                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();

        synchronized (a) {
            Thread.sleep(10000);
            synchronized (b) {
                System.out.println("xx");
            }
        }

        System.out.println("end");
    }
}
